package com.pig4cloud.pig.village.masterdata.controller;

import com.pig4cloud.pig.common.core.util.R;
import com.pig4cloud.pig.village.api.dto.MasterDataDTO;
import com.pig4cloud.pig.village.api.enums.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Will Hu
 * @date 2021/3/26
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/masterdata")
@Api(value = "masterdata", tags = "主数据")
public class MasterDataController {

	@ApiOperation(value = "拥军拥属类型")
	@GetMapping("/army")
	public R<List<MasterDataDTO>> getArmyTypeList() {
		return R.ok(Arrays.stream(Army.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "性别类型")
	@GetMapping("/gender")
	public R<List<MasterDataDTO>> getGenderTypeList() {
		return R.ok(Arrays.stream(Gender.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "困难人群类型")
	@GetMapping("/hard-group")
	public R<List<MasterDataDTO>> getHardGroupTypeList() {
		return R.ok(Arrays.stream(HardGroup.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "居住类型")
	@GetMapping("/living-type")
	public R<List<MasterDataDTO>> getLivingTypeTypeList() {
		return R.ok(Arrays.stream(LivingType.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "医保类型")
	@GetMapping("/medical-insurance")
	public R<List<MasterDataDTO>> getMedicalInsuranceTypeList() {
		return R.ok(Arrays.stream(MedicalInsurance.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "外来家属类型")
	@GetMapping("/oursider")
	public R<List<MasterDataDTO>> getOutsiderTypeList() {
		return R.ok(Arrays.stream(Outsider.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "党员类型")
	@GetMapping("/party-member")
	public R<List<MasterDataDTO>> getPartyMemberTypeList() {
		return R.ok(Arrays.stream(PartyMember.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "户籍类型")
	@GetMapping("/register-type")
	public R<List<MasterDataDTO>> getRegisterTypeTypeList() {
		return R.ok(Arrays.stream(RegisterType.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "退役队长类型")
	@GetMapping("/retired-captain")
	public R<List<MasterDataDTO>> getRetiredCaptainTypeList() {
		return R.ok(Arrays.stream(RetiredCaptain.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "退役正副职")
	@GetMapping("/retired-principal")
	public R<List<MasterDataDTO>> getRetiredPrincipalTypeList() {
		return R.ok(Arrays.stream(RetiredPrincipal.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "学校类型")
	@GetMapping("/school")
	public R<List<MasterDataDTO>> getSchoolTypeList() {
		return R.ok(Arrays.stream(School.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "特殊家庭类型")
	@GetMapping("/special-family")
	public R<List<MasterDataDTO>> getSpecialFamilyTypeList() {
		return R.ok(Arrays.stream(SpecialFamily.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

	@ApiOperation(value = "死亡状态")
	@GetMapping("/status")
	public R<List<MasterDataDTO>> getStatusTypeList() {
		return R.ok(Arrays.stream(Status.values()).map(v ->
				new MasterDataDTO(String.valueOf(v.getCode()), v.getDescription())).collect(Collectors.toList()));
	}

}
